package com.yunhe.inspect.task;

import com.yunhe.common.model.ResultObject;
import com.yunhe.inspect.service.DataInspectPlanService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.text.ParseException;

/**
 * @ClassName InspectPlanTask
 * @Description TODO
 * @Author HeTao
 * @Date 2021/11/11 9:03
 * @Version 1.0
 **/
@Api(value = "InspectPlanTask",description = "定时生成巡检工单",tags = "{InspectPlanTask_Task}")
@RestController
@RequestMapping(value = "/inspectPlanTask")
@Slf4j
public class InspectPlanTask {

    @Autowired
    private DataInspectPlanService dataInspectPlanService;

    @ApiOperation("定时处理巡检计划")
    @RequestMapping(value ="/inspectPlanToOrder",method = RequestMethod.POST)
    @Scheduled(cron = "0 0 1 * * ? ")
    @Async
    public ResultObject resetSerialNumber() throws InterruptedException, ParseException {
        log.info("定时处理巡检计划定时任务开始");
        dataInspectPlanService.inspectPlanToOrder();
        log.info("定时处理巡检计划定时任务结束");
        return new ResultObject<>(null);
    }
}
